From: Claudio Cambra Date: Thu, 27 Mar 2025 10:45:13 +0000 (+0100) Subject: gui/macOS: Avoid need to retain/release things in file provider edit locally X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2^2~62^2~1 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=de082e05f3a9fb327af4db744134b0ac18fd5ee5;p=nextcloud-desktop.git gui/macOS: Avoid need to retain/release things in file provider edit locally Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileprovidereditlocallyjob_mac.mm b/src/gui/macOS/fileprovidereditlocallyjob_mac.mm index 28ff7fd5b..ec5ffcc75 100644 --- a/src/gui/macOS/fileprovidereditlocallyjob_mac.mm +++ b/src/gui/macOS/fileprovidereditlocallyjob_mac.mm @@ -44,8 +44,7 @@ void FileProviderEditLocallyJob::openFileProviderFile(const QString &ocId) NSFileProviderDomain *const domain = (NSFileProviderDomain *)voidDomain; if (domain == nil) { - qCWarning(lcFileProviderEditLocallyMacJob) << "Could not get domain for account:" - << userId; + qCWarning(lcFileProviderEditLocallyMacJob) << "Could not get domain for account:" << userId; emit notAvailable(); } @@ -56,40 +55,33 @@ void FileProviderEditLocallyJob::openFileProviderFile(const QString &ocId) emit notAvailable(); } - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); - __block NSError *receivedError; - __block NSURL *itemLocalUrl; [manager getUserVisibleURLForItemIdentifier:nsOcId completionHandler:^(NSURL *const url, NSError *const error) { - [url retain]; - [error retain]; - itemLocalUrl = url; - receivedError = error; - dispatch_semaphore_signal(semaphore); - }]; - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); - - Systray::instance()->destroyEditFileLocallyLoadingDialog(); - if (receivedError != nil) { - const auto errorMessage = QString::fromNSString(receivedError.localizedDescription); - qCWarning(lcFileProviderEditLocallyMacJob) << "Error getting user visible URL for item" - << ocId << ":" << errorMessage; - emit notAvailable(); - } else if (itemLocalUrl != nil) { - const auto itemLocalPath = QString::fromNSString(itemLocalUrl.path); - qCDebug(lcFileProviderEditLocallyMacJob) << "Got user visible URL for item" - << ocId << ":" << itemLocalPath; - [NSWorkspace.sharedWorkspace openURL:itemLocalUrl]; - emit finished(); - } else { - qCWarning(lcFileProviderEditLocallyMacJob) << "Got nil user visible URL for item" - << ocId; - emit notAvailable(); - } + dispatch_async(dispatch_get_main_queue(), ^{ + Systray::instance()->destroyEditFileLocallyLoadingDialog(); + }); - [itemLocalUrl release]; - [receivedError release]; + if (error != nil) { + const auto errorMessage = QString::fromNSString(error.localizedDescription); + qCWarning(lcFileProviderEditLocallyMacJob) << "Error getting user visible URL for item:" << errorMessage; + dispatch_async(dispatch_get_main_queue(), ^{ + emit notAvailable(); + }); + } else if (url != nil) { + const auto itemLocalPath = QString::fromNSString(url.path); + qCDebug(lcFileProviderEditLocallyMacJob) << "Got user visible URL for item:" << itemLocalPath; + [NSWorkspace.sharedWorkspace openURL:url]; + dispatch_async(dispatch_get_main_queue(), ^{ + emit finished(); + }); + } else { + qCWarning(lcFileProviderEditLocallyMacJob) << "Got nil user visible URL for item" << ocId; + dispatch_async(dispatch_get_main_queue(), ^{ + emit notAvailable(); + }); + } + }]; } } // namespace OCC::Mac